<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:composition template="section/globalTemplate.xhtml">
	
		<ui:define name="pageTitle">
			Create New Trip Schedule
		</ui:define>
		
		<ui:define name="pageContent">
			<div id="editor">
				<h1>Create a new trip schedule</h1>
			
			<h:message class="message" for="newTripScheduleForm"></h:message>
			<h:form id="newTripScheduleForm" prependId="false">
				<fieldset>
					<legend>Trip Code</legend>
					
					<ol>
						<li>
							<h:outputLabel for="tripCode" value="Trip Code:"></h:outputLabel>
							<h:inputText id="tripCode" value="#{newTripScheduleForm.model.tripCode}"></h:inputText>
							<h:message for="tripCode"></h:message>
						</li>
					</ol>
				</fieldset>
			
				<fieldset>
					<legend>Location</legend>
					
					<ol>
						<li>
							<h:outputLabel for="fromCity" value="From City:"></h:outputLabel>
							<h:inputText id="fromCity" value="#{newTripScheduleForm.routeBean.fromCity}"></h:inputText>
							<h:message for="fromCity"></h:message>
						</li>
						
						<li>
							<h:outputLabel for="toCity" value="To City:"></h:outputLabel>
							<h:inputText id="toCity" value="#{newTripScheduleForm.routeBean.toCity}"></h:inputText>
							<h:message for="toCity"></h:message>				
						</li>
						
						<li>
							<h:outputLabel for="boardingPoint" value="Boarding Point:"></h:outputLabel>
							<h:inputText id="boardingPoint" value="#{newTripScheduleForm.model.boardingPoint}"></h:inputText>
							<h:message for="boardingPoint"></h:message>				
						</li>
						
						<li>
							<h:outputLabel for="droppingPoint" value="Dropping Point:"></h:outputLabel>
							<h:inputText id="droppingPoint" value="#{newTripScheduleForm.model.droppingPoint}"></h:inputText>
							<h:message for="droppingPoint"></h:message>				
						</li>
					</ol>
				</fieldset>
				
				<fieldset>
					<legend>Bus Type</legend>
					<h:form>
					<ol>
						<li>
							<f:ajax event="valueChange" immediate="true" render="@form">
							<h:outputLabel for="selectControl" value="Select a bus type: "></h:outputLabel>
								<h:selectOneMenu id="selectControl"
												 converter="#{busTypeViewBox}"
												 value="#{newTripScheduleForm.selectedBusType}"
												 valueChangeListener="#{busTypeViewBox.selectChanged}">
									<f:selectItems value="#{busTypeViewBox.busTypes}"></f:selectItems>
								</h:selectOneMenu>
							</f:ajax>
						</li>
						
						<li>
							<h:outputLabel for="typeName" value="Type Name: "></h:outputLabel>
							<h:inputText id="typeName" readonly="true" binding="#{busTypeViewBox.typeNameInput}"></h:inputText>
						</li>
						
						<li>
							<h:outputLabel for="seatType" value="Seat Type: "></h:outputLabel>
							<h:inputText id="seatType" readonly="true" binding="#{busTypeViewBox.seatTypeInput}"></h:inputText>
						</li>
						
						<li>
							<h:outputLabel for="seatCount" value="Seat Count: " ></h:outputLabel>
							<h:inputText id="seatCount" readonly="true" binding="#{busTypeViewBox.seatCountInput}"></h:inputText>
						</li>
					</ol>
					</h:form>	
				</fieldset>
				
				<fieldset>
					<legend>Schedule Information</legend>
						<ol>
							<li>
								<h:outputLabel value="Starting Day: " for="startingDate"></h:outputLabel>
								<h:inputText id="startingDate" value="#{newTripScheduleForm.model.startingDate}">
									<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
								</h:inputText>
								<h:message for="startingDate"></h:message>
							</li>
							<li>
								<h:outputLabel value="Ending Day: " for="endingDate"></h:outputLabel>
								<h:inputText id="endingDate" value="#{newTripScheduleForm.model.endingDate}">
									<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
								</h:inputText>
								<h:message for="endingDate"></h:message>
							</li>
							<li>
								<h:outputLabel value="Departure Time: " for="departureTime"></h:outputLabel>
								<h:inputText id="departureTime" value="#{newTripScheduleForm.model.departureTime}">
									<f:convertDateTime pattern="hh:mm"></f:convertDateTime>
								</h:inputText>
								<h:message for="departureTime"></h:message>
							</li>
							<li>
								<h:outputLabel value="Departure Time: " for="fare"></h:outputLabel>
								<h:inputText id="fare" value="#{newTripScheduleForm.model.fare}">
									<f:convertNumber />
								</h:inputText>
								<h:message for="fare"></h:message>
							</li>
						</ol>
				</fieldset>
				
				<fieldset>
					<h:commandButton value="Create Trip Schedule" action="#{newTripScheduleForm.createNewSchedule}"></h:commandButton>				
				</fieldset>
			</h:form>	
			</div>
			<!-- end editor -->
		</ui:define>
	
	</ui:composition>
</html>